<div class="dialog-blacklist dialog hidden">
    <div class="box">
        <div class="title">
            <h4 class="fl">列入黑名单对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr><th width="80">原因：</th>
                <td>
                    <select name="bl-reason" onchange="fn_ChangeReason();">
                        <option value="">--请选择原因--</option>
                        <volist name="blacklistReason" id="vo">
                            <option value="{$vo.zxyear}">{$vo.name}</option>
                        </volist>
                    </select>
                    <label style="margin-left:10px;color:red;">*必填项</label>
                </td>
            </tr>
            <tr><th>执行年限：</th>
                <td><input style="width:100px;" disabled="disabled" type="text" name="bl-zxyear" /> （年）</td>
            </tr>
            <tr><th>备注：</th>
                <td>
                    <textarea style="width:210px;" name="bl-remarks"></textarea>
                </td></tr>
            <tr><td colspan="2" style="text-align: center;line-height:40px;">
                <input name="bl-name" value="{$info.name}" type="hidden" type="text" />
                <input name="bl-idno" value="{$info.idno}" type="hidden" type="text" />
                <input name="bl-phone" value="{$info.phone}" type="hidden" type="text" />
                <button class="btn btn-highlight" onclick="action_addBlacklist();">提交</button>
                <span>或</span>
                <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
            </td></tr>
        </table>
    </div>
</div>
<script>

    function fn_ChangeReason(){
        var zxyear = $("select[name='bl-reason']").val();
        $("input[name=bl-zxyear]").val(zxyear);
    }

    /* 黑名单相关处理 */
    function action_blacklist(){
        var dataIds = new Array();
        dataIds.push( $("input[name=id]").val() );
        if(dataIds.length==0){
            alert("请选择申请对象");
            return false;
        }
        $(".dialog-blacklist").show();
    }

    function action_addBlacklist() {
        var reason = $("select[name='bl-reason'] option:selected").text();
        var zxyear = $("input[name=bl-zxyear]").val();
        var remarks = $("textarea[name=bl-remarks]").val();
        if(!reason){
            alert("请输入原因");
            return false;
        }
        var info = {
            name: $("input[name=bl-name]").val(),
            idno: $("input[name=bl-idno]").val(),
            phone: $("input[name=bl-phone]").val(),
        };
        $.ajax({
            url:"/admin/blacklist/ajax_addBlacklist",
            data: {info:info,reason:reason,zxyear:zxyear,remarks:remarks}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("操作成功");
                    $(".dialog").hide();
                    $(".blacklist-state").html("(已列入黑名单)");
                }else{
                    alert(data.info);
                }
            }
        });
    }

    /**
     * 关闭对话框
     */
    function closeDialog() {
        $(".dialog").hide();
    }
</script>
